﻿using System;
using System.Data;
using System.Web.UI;
using CHONET.Common;
using CHONET.DataAccessLayer.Web;
using Infragistics.WebUI.UltraWebGrid;

public partial class Adm_NewsAdmin : Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if ((Common.LoaiNguoiDungID() != 3) && (Common.LoaiNguoiDungID() != 2))
        {
            Response.Redirect("../message.aspx?msg=Access denied");
        }
        if (!Page.IsPostBack)
        {
            LoadData();
        }
    }

    protected void pnlTinTuc_ContentRefresh(object sender, EventArgs e)
    {
        LoadData();
    }

    private void LoadData()
    {
        TinTuc tt = new TinTuc();
        DataSet ds;

        if (Cache["tintuc"] == null)
        {
            ds = tt.SelectTinTucByNguoiDungID(Common.NguoiDungID());
            Cache["tintuc"] = ds;
        }
        else
        {
            ds = (DataSet) Cache["tintuc"];
        }

        grdTinTuc.DataSource = ds.Tables[0];
        grdTinTuc.DataBind();
    }

    protected void grdTinTuc_InitializeLayout(object sender, LayoutEventArgs e)
    {
        //e.Layout.Grid.Columns.FromKey("Command").AllowRowFiltering = false;
        //e.Layout.Grid.Columns.FromKey("TieuDe").FilterOperatorDefaultValue = FilterComparisionOperator.Contains;
        //e.Layout.Grid.Columns.FromKey("TomTat").FilterOperatorDefaultValue = FilterComparisionOperator.Contains;
        //if (rbtTatCa.Checked == true)
        //{
        //    e.Layout.Pager.AllowPaging = false;
        //}
        //else
        //{
        //    e.Layout.Pager.AllowPaging = true;
        //}
    }
}